﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.UI.HtmlControls;

public partial class Guest_Gallery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string imagePath = "Gallery/Image";
        string thumbnailPath = "Gallery/Thumbnails";
        DirectoryInfo directory = new DirectoryInfo(Server.MapPath(imagePath));
        FileInfo[] files = directory.GetFiles();
        string control = @"<ul class=""portfolio clearfix"">" ;     
        for (int i = 0; i < files.Length; i++)
        {
            control += string.Format(@"<li class=""box""><a href=""{2}/{1}"" title=""Image{3}"" class=""magnifier"" ><img src=""{0}/{1}"" alt=""Image{3}""/></a></li>",thumbnailPath, files[i].Name.ToString(), imagePath, i + 1);          
        }
        control += "</ul>";
        if (control != string.Empty)
        {
            HtmlGenericControl div = new HtmlGenericControl();
            div.ID = "containDiv";
            div.InnerHtml = control;
            galleryDiv.Controls.Add(div);
        }
    }
}